import { imgUtil } from '../../../../util/centerUtil'
import { WeaPopoverHrm } from 'ecCom';
class EcontentItem extends React.Component {

  state = {
    hover: false
  }
  adjustHtml = (data='') => {
    let remarkStr =  '<div class="wrap_box">'+ data +'</div>';
    let remarkElement = $(remarkStr);
    remarkElement.children().filter(".container_form_wrap") && remarkElement.children().filter(".container_form_wrap").remove();
    // remarkElement.children().filter("span:not(#wea_rich_text_default_font)") && remarkElement.children().filter('span:not(#wea_rich_text_default_font)').remove();
    let newStr = remarkElement.html();
    let str = imgUtil(newStr);
    str = str.replace(/<img.*?>/g, '[图片]');
    str = str.replace(/<\/p>|<\/td>|<br>/g, '  ')
    str = str.replace(/\r|\n|\\s/gm, "");
    str = str.replace(/<[^>]*>|<\/[^>]*>/gm, "")
    return str;
  }
 
  hoverEnter = () => {this.setState({hover: true})}
  hoverLeave = () => this.setState({hover: false});
  render() {
    const { data,doRefresh } = this.props;
    const { hover }= this.state;
    return ( 
      <div className='ele-item'>
        <p  className={hover?  'wf-name-title hover': 'wf-name-title' }
            title={data.requestnametitle}
            ref={ref => this.refs.title = ref} 
            onMouseEnter ={this.hoverEnter}
            onMouseLeave={this.hoverLeave}
            dangerouslySetInnerHTML={{__html:data.requestname}}
        ></p>
        <div className='info-wd'>
          {
            data.operatename && [
              <WeaPopoverHrm ecId={`${this && this.props && this.props.ecId || ''}_WeaPopoverHrm@6w2gzv@${data.operator}`} />,
              <a className='creater'  
                href={`javaScript:openhrm(${data.operator});`}
                onClick={e => window.pointerXY(e)} 
                title={data.operatename}>
                  {data.operatename}
              </a>
            ]
          }
          <p>{data.operatedate}  {data.operatetime}</p>
        </div>
         <div className='sign-content-div'>
           <div className={'wea-cl-content'}  dangerouslySetInnerHTML={{ __html: this.adjustHtml(data.remark_html) }}></div>
        </div>
        
      </div>
    ) 
  }
}
export default EcontentItem;



